package com.device.operating.service.impl;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.domain.Sort.Order;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.device.operating.dao.DepartmentRepository;
import com.device.operating.dao.GroupRepository;
import com.device.operating.dao.RoleRepository;
import com.device.operating.dao.UgRepository;
import com.device.operating.dao.UgfuncRepository;
import com.device.operating.dao.UserRepository;
import com.device.operating.entity.Department;
import com.device.operating.entity.Func;
import com.device.operating.entity.Grouptab;
import com.device.operating.entity.Role;
import com.device.operating.entity.Ugfunc;
import com.device.operating.entity.User;
import com.device.operating.service.DepartmentService;
import com.device.operating.service.FuncService;
import com.device.operating.service.GroupService;
import com.device.operating.service.RoleService;
import com.device.operating.service.UgfuncService;
import com.device.operating.service.UserService;

@Service("UgfuncService")
@Transactional(propagation=Propagation.REQUIRED)
public class UgfuncServiceImpl implements UgfuncService{
	
	@Autowired
	private UgfuncRepository UgfuncRepository;

	@Override
	public void addugfunc(Ugfunc ugfunc) {
		// TODO Auto-generated method stub
		UgfuncRepository.save(ugfunc);
	}

	@Override
	public void deleteugfunc(String ugfuncId) {
		// TODO Auto-generated method stub
		UgfuncRepository.delete(ugfuncId);
	}

	@Override
	public void deleteugfuncbyugId(String ugId) {
		// TODO Auto-generated method stub
		List<Ugfunc> list=UgfuncRepository.findByUgId(ugId);
		for(Ugfunc uf:list){
			UgfuncRepository.delete(uf.getUgfuncId());
		}
	}

	@Override
	public List<Ugfunc> querybyugIdandugtype(String ugId, String ugtype) {
		// TODO Auto-generated method stub
		return UgfuncRepository.findByUgtypeAndUgId(ugtype, ugId);
	}

	@Override
	public Ugfunc querybyugIdandugtypeandfuncId(String funcId, String ugId,
			String ugtype) {
		// TODO Auto-generated method stub
		return UgfuncRepository.findByUgtypeAndUgIdAndFuncId(ugtype, ugId, funcId);
	}

	@Override
	public Ugfunc querybyugIdandugtypeandfunccode(String ugId, String ugtype,
			String funccode) {
		// TODO Auto-generated method stub
		return UgfuncRepository.findByUgtypeAndUgIdAndFunccode(ugtype, ugId, funccode);
	}

	
	
}
